package com.openbravo.pos.payment;

import com.openbravo.pos.forms.AppConfig;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.util.AltEncrypter;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;

public class ConfigPaymentPanelCaixa extends JPanel
  implements PaymentConfiguration
{
  private JCheckBox jCheckBox1;
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JLabel jLabel4;
  private JTextField jtxtCommerceCode;
  private JPasswordField jtxtCommerceSign;
  private JTextField jtxtCommerceTerminal;

  public ConfigPaymentPanelCaixa()
  {
    initComponents();
  }

  public JPanel getComponent()
  {
    return this;
  }

  public void loadProperties(AppConfig paramAppConfig)
  {
    String str1 = paramAppConfig.getProperty("payment.commerceid");
    String str2 = paramAppConfig.getProperty("payment.terminal");
    String str3 = paramAppConfig.getProperty("payment.commercesign");
    String str4 = paramAppConfig.getProperty("payment.SHA");
    if ((str1 != null) && (str2 != null) && (str3 != null) && (str4 != null) && (str3.startsWith("crypt:")))
    {
      this.jtxtCommerceCode.setText(paramAppConfig.getProperty("payment.commerceid"));
      AltEncrypter localAltEncrypter = new AltEncrypter("cypherkey");
      this.jtxtCommerceTerminal.setText(comboValue(paramAppConfig.getProperty("payment.terminal")));
      this.jtxtCommerceSign.setText(localAltEncrypter.decrypt(paramAppConfig.getProperty("payment.commercesign").substring(6)));
      this.jCheckBox1.setSelected(Boolean.valueOf(paramAppConfig.getProperty("payment.SHA")).booleanValue());
    }
  }

  public void saveProperties(AppConfig paramAppConfig)
  {
    paramAppConfig.setProperty("payment.commerceid", comboValue(this.jtxtCommerceCode.getText()));
    paramAppConfig.setProperty("payment.terminal", comboValue(this.jtxtCommerceTerminal.getText()));
    AltEncrypter localAltEncrypter = new AltEncrypter("cypherkey");
    paramAppConfig.setProperty("payment.commercesign", "crypt:" + localAltEncrypter.encrypt(new String(this.jtxtCommerceSign.getPassword())));
    paramAppConfig.setProperty("payment.SHA", comboValue(Boolean.valueOf(this.jCheckBox1.isSelected())));
  }

  private String comboValue(Object paramObject)
  {
    return paramObject == null ? "" : paramObject.toString();
  }

  private void initComponents()
  {
    this.jLabel1 = new JLabel();
    this.jLabel2 = new JLabel();
    this.jLabel3 = new JLabel();
    this.jLabel4 = new JLabel();
    this.jtxtCommerceCode = new JTextField();
    this.jtxtCommerceSign = new JPasswordField();
    this.jCheckBox1 = new JCheckBox();
    this.jtxtCommerceTerminal = new JTextField();
    this.jLabel1.setText(AppLocal.getIntString("label.merchantcode"));
    this.jLabel2.setText(AppLocal.getIntString("label.terminal"));
    this.jLabel3.setText(AppLocal.getIntString("label.commercesign"));
    this.jLabel4.setText(AppLocal.getIntString("label.sha"));
    this.jCheckBox1.setText("Ampliado");
    GroupLayout localGroupLayout = new GroupLayout(this);
    setLayout(localGroupLayout);
    localGroupLayout.setHorizontalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.jLabel1).addComponent(this.jLabel2).addComponent(this.jLabel3).addComponent(this.jLabel4)).addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addGap(42, 42, 42).addComponent(this.jCheckBox1)).addGroup(localGroupLayout.createSequentialGroup().addGap(46, 46, 46).addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(this.jtxtCommerceTerminal, -2, 180, -2).addComponent(this.jtxtCommerceSign, -2, 180, -2).addComponent(this.jtxtCommerceCode, -2, 180, -2)))).addContainerGap(288, 32767)));
    localGroupLayout.setVerticalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel1).addComponent(this.jtxtCommerceCode, -2, -1, -2)).addGap(6, 6, 6).addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel2).addComponent(this.jtxtCommerceTerminal, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel3).addComponent(this.jtxtCommerceSign, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel4).addComponent(this.jCheckBox1)).addContainerGap(-1, 32767)));
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.payment.ConfigPaymentPanelCaixa
 * JD-Core Version:    0.6.0
 */